package com.weather.modules.controller;

import com.weather.common.vo.WeatherResponse;
import com.weather.modules.service.CityWeatherData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api("用户获取天气信息")
@RequestMapping("/weather")
@RestController
public class CityWeatherController {

    @Autowired
    private CityWeatherData cityWeatherData;

    @ApiOperation("根据城市id获取该城市天气信息")
    @RequestMapping(path = "/getCity",method = RequestMethod.GET)
    public WeatherResponse getCity(String cityId) {
        if (cityId == null && cityId.isEmpty()) {
            return null;
        }
        // String key = UrlConstants.WEATHER_URI + "citykey=" + cityId;
        return this.cityWeatherData.getCity(cityId);
    }
}
